﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Project
{
    public partial class YKxiu : Form
    {
        public int id;
        public YKxiu()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void YKxiu_Load(object sender, EventArgs e)
        {
            
            s();

        }
        public void s() 
        {
            string sql = "select * from ResvInfo where RvId =" + id;
            SqlDataReader reader = FrmHotel.DBHelper.SelectMore(sql);
            if(reader.Read())
            {
                this.textBox1.Text = reader["RvName"].ToString();
                this.textBox2.Text = reader["RvPhone"].ToString();
            }
            reader.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            yKxiu();
            this.Close();
        }
        public void yKxiu() 
        {
            string name = this.textBox1.Text;
            string phone = this.textBox2.Text;
            if(string.IsNullOrEmpty(name)||string.IsNullOrEmpty(phone))
            {
                MessageBox.Show("请填写完整！");
                return;
            }
            string sqls = string.Format("update ResvInfo set RvName='{0}',RvPhone='{1}' where RvId={2}", name,phone,id);
            int result = FrmHotel.DBHelper.ExecuteUpdate(sqls);
            if (result > 0)
            {
                MessageBox.Show("修改成功");
            }
            else 
            {
                MessageBox.Show("修改失败");
            }
        }
    }
}
